/*
 * 项目名称:    wms-server-jeecg
 * 创建人员:    DongPeng
 * 创建时间:    2023-09-21
 * copyright(c) 2022 无锡星智数服科技有限公司
 */
package org.jeecg.modules.dock.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.BeanUtil;
import org.jeecg.modules.basic.warehouse.entity.WmsBasicWarehouse;
import org.jeecg.modules.basic.warehouse.entity.vo.WarehouseSub;
import org.jeecg.modules.basic.warehouse.entity.vo.WmsBasicWarehouseVO;
import org.jeecg.modules.basic.warehouse.service.IWmsBasicWarehouseService;
import org.jeecg.modules.business.repertory.service.IWmsRepertoryService;
import org.jeecg.modules.dock.aspect.DockLog;
import org.jeecg.modules.dock.constant.SystemConstants;
import org.jeecg.modules.dock.entity.mes.request.*;
import org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO;
import org.jeecg.modules.dock.handler.MesLogicHandler;
import org.jeecg.modules.dock.service.MesDockingService;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 提供Mes调用
 *
 * @author DongPeng
 * @version 1.0.0
 * @date 2023-09-21
 * @description 类描述
 */
@AllArgsConstructor
@RestController
@Slf4j
@RequestMapping("/dock/mes")
@Api(tags = "mes调用controller")
@DockLog(source = SystemConstants.MES)
public class MesDockingController {

    private final MesDockingService mesDockingService;

    private final MesLogicHandler mesLogicHandler;

    private final IWmsRepertoryService repertoryService;

    private final IWmsBasicWarehouseService wmsBasicWarehouseService;

    /**
     * 包含强制完成
     *
     * @param vo
     * @return
     */
    @PostMapping("/updateStatus")
    @ApiOperation(value = "任务状态更新", notes = "任务状态更新")
    public MesBaseResponseVO updateStatus(@RequestBody MesBaseRequestVO vo) {
        return mesDockingService.updateStatus(vo);
    }

    @PostMapping("/handle")
    @ApiOperation(value = "MES-WMS通用接口", notes = "MES-WMS通用接口")
    @DockLog(source = SystemConstants.MES,index = 1)
    public MesBaseResponseVO handle(@RequestHeader("businessCode") String businessCode,
                                    @RequestBody String requestVO) {
        return mesLogicHandler.handle(businessCode, requestVO);
    }

    @PostMapping("/scoringStorage")
    @ApiOperation(value = "MES-WMS发送刻痕入库请求", notes = "MES-WMS发送刻痕入库请求")
    public MesBaseResponseVO scoringStorage(@RequestBody @Valid ScoringStorageOrScratchRequestVO scoringStorageRequestVO) {
        return mesDockingService.scoringStorage(scoringStorageRequestVO);
    }

    @PostMapping("/longitudinalShearStorage")
    @ApiOperation(value = "MES-WMS发送纵剪入库请求", notes = "MES-WMS发送纵剪入库请求")
    public MesBaseResponseVO longitudinalShearStorage(@RequestBody @Valid LongitudinalShearStorageRequestVO longitudinalShearStorageRequestVO) {
        return mesDockingService.longitudinalShearStorage(longitudinalShearStorageRequestVO);
    }

    @PostMapping("/verticalCuttingIsCalledPaperTube")
    @ApiOperation(value = "MES-WMS发送纵剪叫纸筒", notes = "MES-WMS发送纵剪叫纸筒")
    public MesBaseResponseVO verticalCuttingIsCalledPaperTube(@RequestBody @Valid VerticalCuttingIsCalledPaperTubeRequestVO vo) {
        return mesDockingService.verticalCuttingIsCalledPaperTube(vo);
    }

    @PostMapping("/verticalAndHorizontalCutting")
    @ApiOperation(value = "MES-WMS发送纵横剪退纸筒", notes = "MES-WMS发送纵横剪退纸筒")
    public MesBaseResponseVO verticalAndHorizontalCutting(@RequestBody @Valid VerticalAndHorizontalCuttingRequestVO vo) {
        return mesDockingService.verticalAndHorizontalCutting(vo);
    }

    @PostMapping("/laminatedAuxiliaryMaterialOrdering")
    @ApiOperation(value = "MES-WMS发送叠片辅材叫料请求（200#、300#、400#、600#）", notes = "MES-WMS发送叠片辅材叫料请求（200#、300#、400#、600#）")
    public MesBaseResponseVO laminatedAuxiliaryMaterialOrdering(@RequestBody @Valid LaminatedAuxiliaryMaterialOrderingRequestVO vo) {
        return mesDockingService.laminatedAuxiliaryMaterialOrdering(vo);
    }

    @PostMapping("/laminatedAuxiliaryMaterialReturn")
    @ApiOperation(value = "MES-WMS发送叠片辅材退料请求（200#、300#、400#、600#）", notes = "MES-WMS发送叠片辅材退料请求（200#、300#、400#、600#）")
    public MesBaseResponseVO laminatedAuxiliaryMaterialReturn(@RequestBody @Valid LaminatedAuxiliaryMaterialReturnRequestVO vo) {
        return mesDockingService.laminatedAuxiliaryMaterialReturn(vo);
    }

    @PostMapping("/packagingLineMaterialOrdering")
    @ApiOperation(value = "MES-WMS发送包装线叫料请求", notes = "MES-WMS发送包装线叫料请求")
    public MesBaseResponseVO packagingLineMaterialOrdering(@RequestBody @Valid PackagingLineMaterialOrderingRequestVO vo) {
        return mesDockingService.packagingLineMaterialOrdering(vo);
    }

    @PostMapping("/packagingLineReturn")
    @ApiOperation(value = "MES-WMS发送包装线退料请求", notes = "MES-WMS发送包装线退料请求")
    public MesBaseResponseVO packagingLineReturn(@RequestBody @Valid PackagingLineReturnRequestVO vo) {
        return mesDockingService.packagingLineReturn(vo);
    }

    @PostMapping("/finishedProductWarehousing")
    @ApiOperation(value = "MES-WMS发送成品入库请求（定尺）", notes = "MES-WMS发送成品入库请求（定尺）")
    public MesBaseResponseVO finishedProductWarehousing(@RequestBody @Valid FinishedProductWarehousingScaleRequestVO vo) {
        return mesDockingService.finishedProductWarehousing(vo);
    }

    @PostMapping("/finishedProductWarehousingIron")
    @ApiOperation(value = "MES-WMS发送成品入库请求（铁心）", notes = "MES-WMS发送成品入库请求（铁心）")
    public MesBaseResponseVO finishedProductWarehousingIron(@RequestBody @Valid FinishedProductWarehousingIronRequestVO vo) {
        return mesDockingService.finishedProductWarehousingIron(vo);
    }

    @PostMapping("/scoringScratch")
    @ApiOperation(value = "MES-WMS发送刻痕叫料请求", notes = "MES-WMS发送刻痕叫料请求")
    public MesBaseResponseVO scoringScratch(@RequestBody @Valid ScoringReturnOrScratchRequestVO vo) {
        return mesDockingService.scoringScratch(vo);
    }

    @PostMapping("/scoringReturn")
    @ApiOperation(value = "MES-WMS发送刻痕退料请求", notes = "MES-WMS发送刻痕退料请求")
    public MesBaseResponseVO scoringReturn(@RequestBody @Valid ScoringReturnOrScratchRequestVO vo) {
        return mesDockingService.scoringReturn(vo);
    }

//    @PostMapping("/scoringStorageOrScratch")
//    @ApiOperation(value = "MES-WMS发送刻痕入库请求", notes = "MES-WMS发送刻痕入库请求")
//    public MesBaseResponseVO scoringStorageOrScratch(@RequestBody @Valid ScoringStorageOrScratchRequestVO vo) {
//        return mesDockingService.scoringStorageOrScratch(vo);
//
//    }

    @PostMapping("/returnSteelBarrel")
    @ApiOperation(value = "MES-WMS发送纵剪退钢筒", notes = "MES-WMS发送纵剪退钢筒")
    public MesBaseResponseVO returnSteelBarrel(@RequestBody @Valid ReturnSteelBarrelRequestVO vo) {
        return mesDockingService.returnSteelBarrel(vo);
    }


    /**
     * MES-WMS发送横剪叫料请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:44
     */
    @PostMapping("/crossShearCallMaterial")
    @ApiOperation(value = "MES-WMS发送横剪叫料请求", notes = "MES-WMS发送横剪叫料请求")
    public MesBaseResponseVO crossShearCallMaterial(@RequestBody @Valid CrossShearCallMaterialRequestVO param) {
        return mesDockingService.crossShearCallMaterial(param);
    }

    /**
     * MES-WMS发送横剪退料请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:44
     */
    @PostMapping("/crossShearingMaterialWithdrawal")
    @ApiOperation(value = "MES-WMS发送横剪退料请求", notes = "MES-WMS发送横剪退料请求")
    public MesBaseResponseVO crossShearingMaterialWithdrawal(@RequestBody @Valid CrossShearingMaterialWithdrawalRequestVO param) {
        return mesDockingService.crossShearingMaterialWithdrawal(param);
    }

    /**
     * MES-WMS发送横剪叫料板请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:44
     */
    @PostMapping("/transverseShearCallMaterialPlate")
    @ApiOperation(value = "MES-WMS发送横剪叫料板请求", notes = "MES-WMS发送横剪叫料板请求")
    public MesBaseResponseVO transverseShearCallMaterialPlate(@RequestBody @Valid TransverseShearCallMaterialPlateRequestVO param) {
        return mesDockingService.transverseShearCallMaterialPlate(param);
    }

    /**
     * MES-WMS发送横剪叫废料箱请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:44
     */
    @PostMapping("/transverseShearCalledScrapBox")
    @ApiOperation(value = "MES-WMS发送横剪叫废料箱请求", notes = "MES-WMS发送横剪叫废料箱请求")
    public MesBaseResponseVO transverseShearCalledScrapBox(@RequestBody @Valid TransverseShearCalledScrapBoxRequestVO param) {
        return mesDockingService.transverseShearCalledScrapBox(param);
    }

    /**
     * MES-WMS发送横剪退废料箱请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:45
     */
    @PostMapping("/crossCutTheScrapBin")
    @ApiOperation(value = "MES-WMS发送横剪退废料箱请求", notes = "MES-WMS发送横剪退废料箱请求")
    public MesBaseResponseVO crossCutTheScrapBin(@RequestBody @Valid CrossCutTheScrapBinRequestVO param) {
        return mesDockingService.crossCutTheScrapBin(param);
    }

    /**
     * MES-WMS发送横剪入库请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:45
     */
    @PostMapping("/scissorEntry")
    @ApiOperation(value = "MES-WMS发送横剪入库请求", notes = "MES-WMS发送横剪入库请求")
    public MesBaseResponseVO scissorEntry(@RequestBody @Valid ScissorEntryRequestVO param) {
        return mesDockingService.scissorEntry(param);
    }

    /**
     * MES-WMS发送叠片叫料请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:45
     */
    @PostMapping("/laminationCall")
    @ApiOperation(value = "MES-WMS发送叠片叫料请求", notes = "MES-WMS发送叠片叫料请求")
    public MesBaseResponseVO laminationCall(@RequestBody @Valid LaminationCallRequestVO param) {
        return mesDockingService.laminationCall(param);
    }

    /**
     * MES-WMS发送叠片退料请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:45
     */
    @PostMapping("/laminationReturn")
    @ApiOperation(value = "MES-WMS发送叠片退料请求", notes = "MES-WMS发送叠片退料请求")
    public MesBaseResponseVO laminationReturn(@RequestBody @Valid LaminationReturnRequestVO param) {
        return mesDockingService.laminationReturn(param);
    }

    /**
     * MES-MES发送叠片叫料完成返回柱料明细
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 9:45
     */
    @PostMapping("/laminationCallMaterialCompletionReturn")
    @ApiOperation(value = "MES-MES发送叠片叫料完成返回柱料明细", notes = "MES-MES发送叠片叫料完成返回柱料明细")
    public MesBaseResponseVO laminationCallMaterialCompletionReturn(@RequestBody @Valid LaminationCallMaterialCompletionReturnColumnMaterialDetails param) {
        return mesDockingService.laminationCallMaterialCompletionReturn(param);
    }

    /**
     * MES-WMS发送叠片退料板请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 10:21
     */
    @PostMapping("/laminatedRefeedingPlate")
    @ApiOperation(value = "MES-WMS发送叠片退料板请求", notes = "MES-WMS发送叠片退料板请求")
    public MesBaseResponseVO laminatedRefeedingPlate(@RequestBody @Valid LaminatedRefeedingPlateRequestVO param) {
        return mesDockingService.laminatedRefeedingPlate(param);
    }

    /**
     * MES-WMS发送纵剪叫料请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 10:23
     */
    @PostMapping("/slittingIsCalledMaterial")
    @ApiOperation(value = "MES-WMS发送纵剪叫料请求", notes = "MES-WMS发送纵剪叫料请求")
    public MesBaseResponseVO slittingIsCalledMaterial(@RequestBody @Valid SlittingIsCalledMaterialRequestVO param) {
        return mesDockingService.slittingIsCalledMaterial(param);
    }

    /**
     * MES-WMS发送纵剪退料请求
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/5 10:23
     */
    @PostMapping("/theMaterialIsWithdrawnByLongitudinalShearing")
    @ApiOperation(value = "MES-WMS发送纵剪退料请求", notes = "MES-WMS发送纵剪退料请求")
    public MesBaseResponseVO theMaterialIsWithdrawnByLongitudinalShearing(@RequestBody @Valid TheMaterialIsWithdrawnByLongitudinalShearingRequestVO param) {
        return mesDockingService.theMaterialIsWithdrawnByLongitudinalShearing(param);
    }

    /**
     * MES-WMS发送纵剪叫托盘
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/25 9:19
     */
    @PostMapping("/theSlittingIsCalledATray")
    @ApiOperation(value = "MES-WMS发送纵剪叫托盘", notes = "MES-WMS发送纵剪叫托盘")
    public MesBaseResponseVO theSlittingIsCalledATray(@RequestBody @Valid TheSlittingIsCalledATrayRequestVO param) {
        return mesDockingService.theSlittingIsCalledATray(param);
    }

    /**
     * MES-WMS发送纵剪叫托盘
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/25 9:19
     */
    @PostMapping("/zjConsumePaper")
    @ApiOperation(value = "MES-WMS发送纵剪消耗纸筒", notes = "MES-WMS发送纵剪消耗纸筒")
    public MesBaseResponseVO zjConsumePaper(@RequestBody @Valid ZJUsePaperRequestVO param) {
        return mesDockingService.zjConsumePaper(param);
    }

    /**
     * MES-WMS发送生产入库（超大卷）
     *
     * @param param
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/25 9:19
     */
    @PostMapping("/scStockSuper")
    @ApiOperation(value = "MES-WMS发送生产入库（超大卷）", notes = "MES-WMS发送生产入库（超大卷）")
    public MesBaseResponseVO scStockSuper(@RequestBody @Valid SCStockSuperRequestVO param) {
        return mesDockingService.scStockSuper(param);
    }

    /**
     * MES-WMS查询库位信息
     *
     * @return org.jeecg.modules.dock.entity.mes.response.MesBaseResponseVO
     * @author hansen
     * @since 2023/10/25 9:19
     */
    @PostMapping("/getLocation")
    @ApiOperation(value = "MES-WMS查询库位信息", notes = "MES-WMS查询库位信息")
    public MesBaseResponseVO getLocation(@RequestBody @Valid RepertoryRequestParam param) {
        return repertoryService.getLocation(param);
    }

    @PostMapping("/warehouse")
    @ApiOperation(value = "MES-WMS查询仓库编码", notes = "MES-WMS查询仓库编码")
    public MesBaseResponseVO warehouse(){
        return MesBaseResponseVO.ok(BeanUtil.copyToList(wmsBasicWarehouseService.list(new LambdaQueryWrapper<WmsBasicWarehouse>()), WarehouseSub.class));
    }
}
